<?php
class Test extends CI_Controller{
	public function index(){
		$target_url = 'http://admin:1234@localhost/CG3002/index.php/webservices/request/item';
		$post = array('item_barcode' => '99983192', 'branch_id' => '1', 'request_amount' => '3000');
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL,$target_url);
		curl_setopt($ch, CURLOPT_POST,1);
		curl_setopt($ch, CURLOPT_USERPWD, "admin:cg3002Adm1n");
		curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
		$result = curl_exec ($ch);
		curl_close ($ch);
		echo var_dump($result);
	}
	
	public function a(){
		$target_url = 'http://admin:1234@localhost/CG3002/index.php/webservices/request/item_received/format/json';
		$post = array('request_id' => '12', 'branch_id' => '2');
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL,$target_url);
		curl_setopt($ch, CURLOPT_POST,1);
		curl_setopt($ch, CURLOPT_USERPWD, "admin:cg3002Adm1n");
		curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
		
		$result = curl_exec ($ch);
		curl_close ($ch);
		echo var_dump($result);
	}
	
	
	public function b(){
		$target_url = 'http://cg3002-06-z.comp.nus.edu.sg/CG3002/index.php/webservices/transaction/send/format/json';
		//$target_url = 'http://localhost/CG3002/index.php/webservices/transaction/send/format/json';
		$file_name_with_full_path = realpath('C:/Users/J/Dropbox/NUS/2013Year4Sem1/CG3002/as.csv');
		$post = array('branch_id' => '15','transaction_profit' => '4200.12' ,'userfile'=>'@'.$file_name_with_full_path);
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL,$target_url);
		curl_setopt($ch, CURLOPT_POST,1);
		curl_setopt($ch, CURLOPT_USERPWD, "admin:cg3002Adm1n");
		curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
		$result=curl_exec ($ch);
		curl_close ($ch);
		echo var_dump($result);
	}
}